package it.gnocco.properties;

import java.io.BufferedReader;
import java.io.File;
import java.io.FileReader;
import java.util.HashMap;

public class Property {
	public static HashMap<String,String> proprieta = new HashMap<String,String>(); 
	private static final String CLASS = "Property";

	public Property(){
		this(new File("ML.properties"));
	}
	
	public Property(File file){
		FileReader fr;
		try {
			fr = new FileReader(file);
			BufferedReader br = new BufferedReader(fr);
			String line = "";
			while((line = br.readLine())!=null){
				String nome = line.split("=")[0].trim();
				String valore = "";
				if(line.split("=").length>1)
					valore = line.split("=")[1].trim();
				if(!valore.equals("")){
					proprieta.put(nome, valore);
				}
			}
			br.close();
			fr.close();
		} catch (Exception e) {
			e.printStackTrace();
		}
		
	}
	
	public String get(String nome){
		String result = "";
		if(proprieta.keySet().contains(nome)){
			result = proprieta.get(nome);
			
		}else{
			result = "";
		}
		return result;
	}
}
